package com.desmart.ht.view;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.desmart.ht.EyeActivity;
import com.desmart.ht.R;
import com.desmart.ht.ScreeningActivity;
import com.desmart.ht.ShareActivity;

public class SetPopView extends PopupWindow implements View.OnClickListener {

    private Context context;

    public SetPopView(Context context){
        this.context = context;
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.popup_set_view, null);
        this.setContentView(view);
        this.setFocusable(true);
        this.setOutsideTouchable(true);
        this.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT);
        this.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);
        this.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00000000")));
        initView(view);
    }

    private void initView(View v) {
        TextView tvScreening = v.findViewById(R.id.tv_screening);
        TextView tvShare = v.findViewById(R.id.tv_share);
        tvScreening.setOnClickListener(this);
        tvShare.setOnClickListener(this);
    }

    public void show(View v){
        this.showAsDropDown(v);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.tv_screening){
            ScreeningActivity.start(context);
        }
        if (view.getId() == R.id.tv_share){
            ShareActivity.start(context);
        }
        this.dismiss();
    }
}
